﻿// Copyright (c) Inossem. All rights reserved.
// Licensed under the LGPL-3.0 license. See LICENSE file in the project root for full license information.
using DWF.Studio.Share.Utils;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace DWF.Studio.Binding
{
    public class LocalPathRule : ValidationRule
    {
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            if (value == null)
            {
                return new ValidationResult(false, "不能为空值！");
            }

            if (string.IsNullOrEmpty(value.ToString()))
            {
                return new ValidationResult(false, "不能为空字符串！");
            }

            if (!FileHelper.CheckFolderExisting(value.ToString()))
            {
                return new ValidationResult(false, "路径错误！");
            }

            return new ValidationResult(true, null);
        }
    }
}
